home *** CD-ROM | disk | FTP | other *** search
- type
- keyRec = record
- key theKey : string;
- theVal : string;
- endRecord
- endType
-
- var
- session : string = '';
- targetFile : string = '';
- itemID : string = '';
- ARec : keyRec;
- subs : table of keyRec;
- items : table of keyRec;
- prices : table of keyRec;
- totalOrder : real = 0;
- totalProducts : longint = 0;
- totalWeight : real = 0;
- subItems : longint = 0;
- si : integer;
- theSubItem : string;
- theValue : longint;
- oldProdNum : longint;
- thePrice : real;
- theWeight : real;
- tempStr : string;
- endVar
-
- function strToInt(s : string) : longint;
- var
- r : real;
- endVar
- val(s, r);
- strToInt := r;
- endProc
-
- function strToReal(s : string) : real;
- var
- r : real;
- endVar
- val(s, r);
- strToReal := r;
- endProc
-
- function intToStr(i : longint) : string;
- var
- s : string;
- endVar
- str(i : 0 : 0, s);
- return s;
- endProc
-
- function realToStr(r : real) : string;
- var
- s : string;
- endVar
- str(r : 0 : 2, s);
- return s;
- endProc
-
- procedure main
- session := fieldParm('SessionID');
- if ((session = '') or (session = '*SeSiOnId*'))
- printError;
- return;
- endif
- targetFile := cgiParm('Physical Path');
- itemID := fieldParm('ItemID');
- writeTitle('Catalog Maker Product Mark');
- loadTable(subs, 'items.db');
- loadTable(items, session);
- loadTable(prices, 'prices.db');
-
- ARec.theKey := 'TotalOrder';
- setKeysFromRecord(items, ARec);
- if (readRecord(items, ARec))
- totalOrder := strToReal(ARec.theVal);
- endif
-
- ARec.theKey := 'TotalProducts';
- setKeysFromRecord(items, ARec);
- if (readRecord(items, ARec))
- totalProducts := strToInt(ARec.theVal);
- endif
-
- ARec.theKey := 'TotalWeight';
- setKeysFromRecord(items, ARec);
- if (readRecord(items, ARec))
- totalWeight := strToReal(ARec.theVal);
- endif
-
- ARec.theKey := itemID;
- setKeysFromRecord(subs, ARec);
- if (readRecord(subs, ARec))
- subItems := strToInt(ARec.theVal);
- endif
- if (subItems <> 0)
- for si := 1 to subItems
- theSubItem := itemID + intToStr(si);
- tempStr := fieldParm(theSubItem);
- theValue := strToInt(tempStr);
- ARec.theKey := theSubItem;
- setKeysFromRecord(items, ARec);
- if (readRecord(items, ARec))
- oldProdNum := strToInt(ARec.theVal);
- else
- oldProdNum := 0;
- endif
- totalProducts := totalProducts - oldProdNum + theValue;
-
- ARec.theKey := theSubItem;
- setKeysFromRecord(prices, ARec);
- if (readRecord(prices, ARec))
- thePrice := strToReal(ARec.theVal)
- else
- thePrice := 0;
- endif
- totalOrder := totalOrder + ((theValue - oldProdNum) * thePrice);
-
- ARec.theKey := theSubItem + 'W';
- setKeysFromRecord(prices, ARec);
- if (readRecord(prices, ARec))
- theWeight := strToReal(ARec.theVal)
- else
- theWeight := 0;
- endif
- totalWeight := totalWeight + ((theValue - oldProdNum) * theWeight);
-
- ARec.theKey := theSubItem;
- ARec.theVal := intToStr(theValue);
- writeRecord(items, ARec);
- endFor
- endif { there are sub items }
-
- ARec.theKey := 'TotalOrder';
- ARec.theVal := realToStr(totalOrder);
- writeRecord(items, ARec);
-
- ARec.theKey := 'TotalWeight';
- ARec.theVal := realToStr(totalWeight);
- writeRecord(items, ARec);
-
- ARec.theKey := 'TotalProducts';
- ARec.theVal := intToStr(totalProducts);
- writeRecord(items, ARec);
-
- saveTable(items, session);
-
- writeln('The products you specified were marked!');
- writeln('So far you marked ', intToStr(totalProducts),
- ' for a total of $', realToStr(totalOrder));
- writeln('The total weight of the products you ordered is ',
- realToStr(totalWeight));
- writeLink('continue', '/cgi-win/backeng.exe' + fieldParm('TargetPage') +
- '?SessionID=' + session + '&ItemID=' + itemID +
- '&ScriptName=' + fieldParm('TargetScript'));
-
- endProc
-
- procedure printError
- writeTitle('Script Error');
- writeln('Script executed with wrong parameters');
- endProc
-